package homework;

import java.util.ArrayList;

public class judge {
	public static void main(String[] args){
		ArrayList<Integer>list=new ArrayList<>();
		int count=0;
		for(int i=0;i<10;i++){
				int num=i*10+i;
				list.add(num);
			}
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				int num=i*100+j*10+i;
				list.add(num);
			}
		}
		for(int i=0;i<list.size();i++){
			int judge=0,flag=0;
			judge=list.get(i);
			if(judge<2){
				flag=1;
			}else if(judge==2){
				flag=0;
			}else{
				for(int j=2;j<judge-1;j++){
					if(judge%j==0){
						flag=1;
						break;
					}
				}
			}
			if(flag==0){
				count++;
				System.out.print(judge+" ");
				if(count==10){
					System.out.println();
					count=0;
				}
			}
		}
	}
}
